# procedure to apply linear fit
# to a list of files

# it is assumed that mask and calfib have already run.  

# the linear fits are done using the results found for the masked spectra 

# *** WARNING! this task does not yet accept image lists (@ files)

procedure fibint(input)

char    input         {prompt="Images to be linearly fit"}

begin

char curr_mask, sc_mask, base_mask, base2_mask

int i,j 

# iraf doesn't like we use the parameter variables within the script
# so here we make a copy of them to a new variable 
# whose name has an n_ added to the beginning of the name of each of them
# 
char n_input

n_input = input

if (access("lixo0976"))
   del("lixo0976")

if (access("ifu.lin"))
   delete("ifu.lin",verify=no)

sections(images=n_input,option="fullname",>>"lixo0976")
!awk '{print $1 ".fits"}' < "lixo0976" > "ifu.lin"

# we then run lifu with the L option: note that the file ifu.conf must
# exist and be prepared by mask.cl

print("RUN LIFU")
!lifu L >& /dev/null
print("RUN LIFU")

end
